const net = require('net')

const client = net.createConnection({
  port: 1234, 
  host: '127.0.0.1'
})

let dataArray = [
  "拉钩教育1",
  "拉钩教育2",
  "拉钩教育3",
  "拉钩教育4"
]
client.on('connect', () => {
  client.write('拉勾教育')
 for(let i = 0;i<dataArray.length;i++){
   (function(val,index){
     setTimeout(function(){
      client.write(val)
     },1000*index+1)
   })(dataArray[i],i)
 }
})

client.on('data', (chunk) => {
  console.log(chunk.toString())
})

client.on('error', (err) => {
  console.log(err)
})

client.on('close', () => {
  console.log('客户端断开连接')
})